In [4]:
from numpy import sqrt
from qutip import *

In [5]:
H = Qobj([[1],[0]])
V = Qobj([[0],[1]])

Example 8.A.1:


In [6]:
psi = 1/sqrt(2)*tensor(H,H) + 1/sqrt(2)*tensor(V,V)
psi


Out[6]:
Quantum object: dims = [[2, 2], [1, 1]], shape = [4, 1], type = ket\begin{equation*}\left(\begin{array}{*{11}c}0.707\\0.0\\0.0\\0.707\\\end{array}\right)\end{equation*}

In [7]:
rho_ent = psi*psi.dag()

In [8]:
(rho_ent*rho_ent).tr()


Out[8]:
0.9999999999999996

In [9]:
rho_mix = 0.5*tensor(H,H)*tensor(H,H).dag() + 0.5*tensor(V,V)*tensor(V,V).dag()

In [10]:
(rho_mix*rho_mix).tr()


Out[10]:
0.5

Example 8.A.2

Remember the 45 states:


In [11]:
P45 = Qobj([[1/sqrt(2)],[1/sqrt(2)]])
M45 = Qobj([[1/sqrt(2)],[-1/sqrt(2)]])

Create the projection operator for $|+45,+45\rangle$


In [12]:
Proj_4545 = tensor(P45,P45)*tensor(P45,P45).dag()

In [13]:
(Proj_4545*rho_mix).tr()


Out[13]:
(0.2499999999999999+0j)

Create projection operator for $|+45\rangle_i$


In [14]:
Proj_45i = tensor(qeye(2),P45)*tensor(qeye(2),P45).dag()

In [15]:
(Proj_45i*rho_mix).tr()


Out[15]:
(0.4999999999999999+0j)

In [16]:
0.25/0.5


Out[16]:
0.5

Extend the example for the pure (superposition) state


In [17]:
(Proj_4545*rho_ent).tr() / (Proj_45i*rho_ent).tr()


Out[17]:
(0.9999999999999998+0j)

The photons are entanlged and therefore show perfect correlation even in the +45 measurements.